package com.gzq.builder.example1;

import java.util.ArrayList;

public abstract class ProductCarAbstract {
    private ArrayList<String> sequence = new ArrayList<>();

    protected abstract void start();

    protected abstract void stop();

    protected abstract void alarm();

    protected abstract void engineBoom();

    final public void run() {
        for (String str : sequence) {
            if ("start".equalsIgnoreCase(str)){
                this.start();
            }else if ("stop".equalsIgnoreCase(str)){
                this.stop();
            }else if ("alarm".equalsIgnoreCase(str)){
                this.alarm();
            }else if ("engine boom".equalsIgnoreCase(str)){
                this.engineBoom();
            }
        }

    }

    final public void setSequence(ArrayList<String> sequence){
        this.sequence = sequence;
    }

}
